package com.oauth.global.server.controller;

import java.util.List;
import java.util.Set;

import org.springframework.beans.factory.annotation.Required;

import com.oauth.common.server.OAuthGwtController;
import com.oauth.common.server.util.OAuthRequestUtil;
import com.oauth.global.client.beans.AppInfoBean;
import com.oauth.global.client.beans.BirthdayClientBean;
import com.oauth.global.client.rpc.GlobalRemoteService;
import com.oauth.global.server.service.GlobalOAuthService;
import com.oauth.service.application.global.beans.GlobalDataType;

public class GlobalGwtController extends OAuthGwtController implements GlobalRemoteService {

	private static final long serialVersionUID = -5758464341967618224L;

	private GlobalOAuthService mGlobalOAuthService;

	/**
	 * @param pGlobalOAuthService
	 *            the globalOAuthService to set
	 */
	@Required
	public void setGlobalOAuthService(GlobalOAuthService pGlobalOAuthService) {
		mGlobalOAuthService = pGlobalOAuthService;
	}

	@Override
	public boolean updateStatus(String pStatusText, Set<Long> pApplicationIdSet) {
		Long memberId = OAuthRequestUtil.getMemberId(getHttpRequest());
		return mGlobalOAuthService.updateStatus(memberId, pStatusText, pApplicationIdSet);
	}

	@Override
	public List<AppInfoBean> getApplicationImagesForStatus() {
		Long memberId = OAuthRequestUtil.getMemberId(getHttpRequest());
		return mGlobalOAuthService.getApplicationImages(memberId, GlobalDataType.STATUS_UPDATE);
	}

	@Override
	public List<AppInfoBean> getApplicationImagesForBirthday() {
		Long memberId = OAuthRequestUtil.getMemberId(getHttpRequest());
		return mGlobalOAuthService.getApplicationImages(memberId,
				GlobalDataType.BIRTHDAY_NOTIFACTION);
	}

	@Override
	public List<BirthdayClientBean> getUpcomingBirthdays() {
		Long memberId = OAuthRequestUtil.getMemberId(getHttpRequest());
		return mGlobalOAuthService.getUpcomingBirthdays(memberId);
	}

	@Override
	public List<BirthdayClientBean> getUpcomingBirthdays(long pAppId) {
		Long memberId = OAuthRequestUtil.getMemberId(getHttpRequest());
		return mGlobalOAuthService.getUpcomingBirthdays(memberId, pAppId);

	}

}
